<?php
/**
 * Created by PhpStorm.
 * User: moquan
 * Date: 2018/6/20
 * Time: 18:18
 */

namespace app\admin\validate;


class RoleVali extends BaseValidate {

    //定义验证规则
    protected $rule = [
        "role_name" => "require|min:2|max:22",
        "desc" => "max:100",
        "status" => "require",
    ];

    //定义验证提示
    protected $message = [
        "role_name.require" => "角色名称不能为空",
        "role_name.unique" => "角色名称已存在",
        "role_name.min" => "角色名称不能小于2位",
        "role_name.max" => "角色名称不能大于22位",
        "desc.max" => "角色描述不能大于100个字符",
        "status.require" => "角色状态不能为空",
    ];

    //定义验证场景
    protected $scene = [
        //添加
        'add'  =>  ['role_name' => 'require|min:2|max:22|unique:admin_role', 'ids' => 'require', 'desc', 'status'],
        //登录
        'edit'  =>  ['id'=>'require', 'role_name', 'status' ],
        //角色授权
        'auth'  =>  ['ids' => 'require', 'role_id' => 'require']

    ];

    // 自定义验证规则
    /*protected function checkName($value,$rule,$data)
    {
        return '名称错误';
    }*/
}